home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / FWRecShp.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  5.1 KB  |  185 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRecShp.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWRECSHP_H
  13. #include "FWRecShp.h"
  14. #endif
  15.  
  16. #ifndef FWGC_H
  17. #include "FWGC.h"
  18. #endif
  19.  
  20. #ifndef FWGRGLOB_H
  21. #include "FWGrGlob.h"
  22. #endif
  23.  
  24. #ifndef FWGRUTIL_H
  25. #include "FWGrUtil.h"
  26. #endif
  27.  
  28. #ifndef FWFXMATH_H
  29. #include "FWFxMath.h"
  30. #endif
  31.  
  32. #ifndef FWRASTER_H
  33. #include "FWRaster.h"
  34. #endif
  35.  
  36. // ----- Foundation Includes -----
  37.  
  38. #ifndef FWSTREAM_H
  39. #include "FWStream.h"
  40. #endif
  41.  
  42. //========================================================================================
  43. //    RunTime Info
  44. //========================================================================================
  45.  
  46. #if FW_LIB_EXPORT_PRAGMAS
  47. #pragma lib_export on
  48. #endif
  49.  
  50. #ifdef FW_BUILD_MAC
  51. #pragma segment FWGraphics_RectShape
  52. #endif
  53.  
  54. FW_DEFINE_CLASS_M1(FW_CRectShape, FW_CBoundedShape)
  55.  
  56. FW_REGISTER_ARCHIVABLE_CLASS(FW_LRectShape, FW_CRectShape, FW_CRectShape::Read, FW_CShape::Write)
  57.  
  58. //========================================================================================
  59. //    class FW_CRectShape
  60. //========================================================================================
  61.  
  62. //----------------------------------------------------------------------------------------
  63. //    FW_CRectShape::FW_CRectShape
  64. //----------------------------------------------------------------------------------------
  65.  
  66. FW_CRectShape::FW_CRectShape() :
  67.     FW_CBoundedShape(FW_kZeroRect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont)
  68. {
  69.     FW_END_CONSTRUCTOR
  70. }
  71.  
  72. //----------------------------------------------------------------------------------------
  73. //    FW_CRectShape::FW_CRectShape
  74. //----------------------------------------------------------------------------------------
  75.  
  76. FW_CRectShape::FW_CRectShape(const FW_CRectShape& other) :
  77.     FW_CBoundedShape(other)
  78. {
  79.     FW_END_CONSTRUCTOR
  80. }
  81.  
  82. //----------------------------------------------------------------------------------------
  83. //    FW_CRectShape::FW_CRectShape
  84. //----------------------------------------------------------------------------------------
  85.  
  86. FW_CRectShape::FW_CRectShape(const FW_CRect& rect,
  87.                              FW_ERenderVerbs renderVerb,
  88.                              const FW_PInk& ink,
  89.                               const FW_PStyle& style) :
  90.     FW_CBoundedShape(rect, renderVerb, ink, style, FW_kNormalFont)
  91. {
  92.     FW_END_CONSTRUCTOR
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. //    FW_CRectShape::FW_CRectShape
  97. //----------------------------------------------------------------------------------------
  98.  
  99. FW_CRectShape::FW_CRectShape(FW_CReadableStream& archive) :
  100.     FW_CBoundedShape(archive)
  101. {
  102.     FW_END_CONSTRUCTOR
  103. }
  104.  
  105. //----------------------------------------------------------------------------------------
  106. //    FW_CRectShape::~FW_CRectShape
  107. //----------------------------------------------------------------------------------------
  108.  
  109. FW_CRectShape::~FW_CRectShape()
  110. {
  111.     FW_START_DESTRUCTOR
  112. }
  113.  
  114. //----------------------------------------------------------------------------------------
  115. //    FW_CRectShape::Render
  116. //----------------------------------------------------------------------------------------
  117.  
  118. void FW_CRectShape::Render(FW_CGraphicContext& gc) const
  119. {    
  120.     gc.GetRasterizer()->RenderRect(gc,
  121.                                     fRect,
  122.                                     GetRenderVerb(),
  123.                                     fInk,
  124.                                     fStyle);
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. //    FW_CRectShape::RenderRect
  129. //----------------------------------------------------------------------------------------
  130.  
  131. void FW_CRectShape::RenderRect(FW_CGraphicContext& gc,
  132.                                 const FW_CRect& rect, 
  133.                                 FW_ERenderVerbs renderVerb, 
  134.                                 const FW_PInk& ink,
  135.                                 const FW_PStyle& style)
  136. {    
  137.     gc.GetRasterizer()->RenderRect(gc,
  138.                                     rect,
  139.                                     renderVerb,
  140.                                     ink,
  141.                                     style);
  142. }
  143.  
  144. //----------------------------------------------------------------------------------------
  145. //    FW_CRectShape::HitTest
  146. //----------------------------------------------------------------------------------------
  147.  
  148. FW_Boolean FW_CRectShape::HitTest(FW_CGraphicContext& gc,
  149.                                   const FW_CPoint& test,
  150.                                   FW_CFixed tolerance) const
  151. {    
  152.     if (FW_CBoundedShape::HitTest(gc, test, tolerance))
  153.     {
  154.         if (fRenderVerb == FW_kFrame)
  155.         {            
  156.             FW_CRect bounds(fRect);
  157.             FW_CFixed inset = tolerance + GetPenSize();
  158.             bounds.Inset(inset, inset);
  159.             return ! bounds.Contains(test);
  160.         }
  161.         
  162.         return TRUE;
  163.     }
  164.     
  165.     return FALSE;
  166. }
  167.  
  168. //----------------------------------------------------------------------------------------
  169. //    FW_CRectShape::Copy
  170. //----------------------------------------------------------------------------------------
  171.  
  172. FW_CShape* FW_CRectShape::Copy() const
  173. {
  174.     return FW_NEW(FW_CRectShape, (*this));
  175. }
  176.  
  177. //----------------------------------------------------------------------------------------
  178. //    FW_CRectShape::Read
  179. //----------------------------------------------------------------------------------------
  180.  
  181. void* FW_CRectShape::Read(FW_CReadableStream& archive)
  182. {
  183.     return FW_NEW(FW_CRectShape, (archive));
  184. }
  185.